#include "mytime.h"

Time::Time()
{
    hour = 0, minute = 0;
}

Time::Time(int hr, int mi): hour(hr), minute(mi){}

Time::~Time(){}

void Time::AddHour(int hr){ hour += hr;}

void Time::AddMinute(int mi)
{
    minute += mi;
    if (mi >= 60)
    {
        hour += minute / 60;
        minute %= 60;
    }
}

void Time::Reset(int hr, int mi)
{
    minute = mi;
    hour = hr;

    if (mi >= 60)
    {
        hour += minute / 60;
        minute %= 60;
    }
}

void Time::Show() const
{
    std::cout << hour << " - " << minute << std::endl;
}

Time Time::Sum(const Time & t) const
{
    Time res;
    res.minute = minute + t.minute;
    res.hour = hour + t.hour;
    if (res.minute >= 60)
    {
        res.hour += (res.minute / 60);
        res.minute %= 60;
    }
    
    return res;
}

Time Time::operator+(const Time & t) const
{
    return Sum(t);
}